<template>
    <widget-root :styles="styles">
        <div
            class="navigation"
            :style="{
                'border-radius': `${styles.border_radius_top}px ${styles.border_radius_top}px ${styles.border_radius_bottom}px ${styles.border_radius_bottom}px`
            }"
        >
            <div class="navigation-content flex flex-wrap">
                <div
                    v-for="(item, index) in navList"
                    :key="index"
                    class="nav-item "
                    :style="{ width: `calc(${100 / styles.nav_line_num}% - 5px)` }"
                >
                    <div class="nav-item__left">
                        <div class="nav-item__name">{{ item.name }}</div>
                        <div class="nav-item__name2">{{ item.name2 }}</div>
                    </div>
                    <div class="nav-item__right">
                        <el-image
                            :src="$getImageUri(item.url)"
                            style="width: 33px; height: 33px"
                            :style="{
                                'border-radius': `${styles.img_border_radius}px`
                            }"
                        >
                            <div slot="error" class="image-error muted flex row-center">
                                <i class="el-icon-picture font-size-20"></i>
                            </div>
                        </el-image>
                    </div>
                </div>
            </div>

            <div class="navigation-indicator" v-if="styles.nav_style == 2">
                <indicator :type="styles.indicator_style" align="center" :color="styles.indicator_color" :bottom="6" />
            </div>
        </div>
    </widget-root>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from 'vue-property-decorator'
import Indicator from '@/components/decorate/indicator.vue'
import WidgetRoot from '@/components/decorate/widget-root.vue'
@Component({
    components: {
        Indicator,
        WidgetRoot
    }
})
export default class Contents extends Vue {
    @Prop() content!: any
    @Prop() styles!: object | any
    get navList() {
        const {
            content: { data },
            styles: { nav_line, nav_line_num }
        } = this
        if (!Array.isArray(data)) {
            return []
        }
        return data.slice(0, nav_line * nav_line_num)
    }
}
</script>

<style lang="scss" scoped>
.navigation {
    .navigation-content {
        display: flex;
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    .nav-item {
        // margin-bottom: 10px;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 10px;
        padding: 15px;
        background-color: #fff;
        border-radius: 10px;
        
    }
    
    .nav-item__name {
        font-size: 16px;
        font-weight: 700;
        color: #000;
    }
    .nav-item__name2 {
        font-size: 12px;
        color: #999999;
    }
    .nav-item__right {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    .el-image {
        border-radius: 0;
    }
    .navigation-indicator {
        position: relative;
        height: 10px;
    }
}
</style>
